#! /bin/bash

byr_iptv_url="http://iptv.bupt.edu.cn/"

if [ -f "tvlist" ] ; then
	echo "File tvlist has been existed."
else
	echo "Download..."
	wget -q $byr_iptv_url -O iptv.gbk.html
	iconv -f gbk -t utf-8 iptv.gbk.html > iptv.html
	grep "mms" iptv.html | grep td | sed 's/>/\"/g' | sed 's/</\"/g' \
	| awk -F '"' '{printf $7 " " $9 "\n"}' > tvlist
	rm iptv.gbk.html iptv.html
fi
